package zy1208.zy15;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class demo {
    public static void main(String[] args) throws Exception {
        List<Animal> run = run();
        System.out.println(run);

    }
    public static List<Animal> run() throws Exception {
        List<String> lines = FileUtils.readLines(new File("D:\\ideadashuju12\\liu_ya_kai\\src\\zy1208\\zy15\\dataAnimal.txt"));
        List<Animal> list = new ArrayList<>();
        for (String line : lines) {
            String[] s = line.split(" ");
            if (s[0].equals("Cat")){
                String[] split = s[1].split("=");
                String[] split1 = s[2].split("=");
                String[] split2 = s[3].split("=");
                list.add(new Cat(split[1],split1[1],split2[1]));
            }else {
                String[] split = s[1].split("=");
                String[] split1 = s[2].split("=");
                String[] split2 = s[3].split("=");
                list.add(new Dog(split[1],split1[1],Integer.parseInt(split2[1])));
            }
        }
        return list;
    }
}
